//
//  MainSubMainView.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/10/17.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "MainSubMainView.h"

#import "HCPopoverViewController.h"
#import "SDCycleScrollView.h"
#import "STSpaceViewController.h"
#import "StwxDetailViewController.h"
#import "ExpertListV2ViewController.h"
#import "NewsListViewController.h"
#import "DocumentDetailViewController.h"

#import "CommonItemCell.h"
#import "CommonNewsItemCell.h"

// TEST
#import "OptionsPresentViewController.h"

@interface MainSubMainView() <UITableViewDelegate, UITableViewDataSource, UIPopoverPresentationControllerDelegate, SDCycleScrollViewDelegate, UIScrollViewDelegate>

@property (nonatomic, readwrite, strong) MainSubViewModel* viewModel;

// UI
@property (weak, nonatomic) IBOutlet UIView* bannerView;
@property (weak, nonatomic) IBOutlet UIButton* treeBtn;
@property (weak, nonatomic) IBOutlet UIButton* calerBtn;
@property (weak, nonatomic) IBOutlet UIButton* consulationBtn;
@property (weak, nonatomic) IBOutlet UIButton* mechanismBtn;
@property (weak, nonatomic) IBOutlet UILabel* publicityLabel;
@property (weak, nonatomic) IBOutlet UIButton* publicityBtn;
@property (weak, nonatomic) IBOutlet UIButton* todayChangeBtn;
@property (weak, nonatomic) IBOutlet UIButton* todayMoreBtn;
@property (weak, nonatomic) IBOutlet UITableView* todayTableView;
@property (weak, nonatomic) IBOutlet UIButton* expertMoreBtn;
@property (weak, nonatomic) IBOutlet UIView* expertsView;
@property (weak, nonatomic) IBOutlet UIButton* newsChangeBtn;
@property (weak, nonatomic) IBOutlet UIButton* newsMoreBtn;
@property (weak, nonatomic) IBOutlet UITableView* newsTableView;
@property (weak, nonatomic) IBOutlet UIButton* supermanMoreBtn;
@property (weak, nonatomic) IBOutlet UIView* supermansView;

// Test
@property (strong, nonatomic) HCPopoverViewController* popoverVC;

@end

@implementation MainSubMainView

- (void)bindViewModel:(id)viewModel
{
    MainSubViewModel* vm = viewModel;
    
    if (!self.viewModel)
    {
        self.viewModel = vm;
        
        [self _setup];
    }
    else
    {
    }
}

- (void)_setup
{
    @weakify(self)
    
    [self _setupBanner];
    
    // 计税器
    [[self.calerBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
    {
        @strongify(self);
        
        [self _push2JSQ];
    }];
    
    // 生态树
    [[self.treeBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
     {
         @strongify(self);
         
         [self _push2STS];
         
//         OptionsPresentViewController* vc = nil;
//
//         @weakify(self);
//         // 测试更多弹出
//         OptionsPresentViewModel* vm = [[OptionsPresentViewModel alloc] initWithParams:@{}];
//         vm.titles = @[@"标题1", @"标题2", @"标题3"];
//         vm.topTitle = @"顶部标题";
//         vm.selectCmd = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input)
//         {
//             @strongify(self);
//
//             [[UIViewController getCurrentVC] dismissViewControllerAnimated:vc completion:^{
//
//             }];
//
//             return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
//
//                 [subscriber sendCompleted];
//
//                 return nil;
//             }];
//         }];
//         vc = [[OptionsPresentViewController alloc] initWithViewModel:vm];
//         vc.view.backgroundColor = [UIColor clearColor];
////         vc.modalPresentationStyle = UIModalPresentationOverCurrentContext|UIModalPresentationFullScreen;
//         if ([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0) {
//             vc.modalPresentationStyle=UIModalPresentationOverCurrentContext;
//         }else{
//             vc.modalPresentationStyle=UIModalPresentationCurrentContext;
//         }
//         [[UIViewController getCurrentVC] presentViewController:vc animated:YES completion:^
//          {
//              vc.view.backgroundColor = UIColorHex(#0000000f);
//          }];
         
//         //弹出选项
//         HCPopoverViewController *controller = [[HCPopoverViewController alloc] init];
//         controller.titles = @[@"标题1", @"标题2", @"标题3"];
//         controller.topTitle = @"顶部标题";
//         controller.preferredContentSize = CGSizeMake(180, 3 * 44 + 44); // 设置popover出来的视图的大小
//         controller.modalPresentationStyle = UIModalPresentationPopover;
//         self.popoverVC = controller;
//
//         UIPopoverPresentationController *popController = [controller popoverPresentationController];
//         popController.delegate = self;
//         popController.sourceView = self.treeBtn;
//         popController.sourceRect = self.treeBtn.bounds;
//
//         [[UIViewController getCurrentVC] presentViewController:self.popoverVC animated:YES completion:nil];
//
//         @weakify(self)
//         controller.selectCallback = ^(NSIndexPath* indexPath)
//         {
//             @strongify(self)
//
//             [[UIViewController getCurrentVC] dismissViewControllerAnimated:self.popoverVC completion:^{
//
//             }];
//         };
     }];
    
    // 机构列表
    [[self.mechanismBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
     {
         @strongify(self);
         
         [self.viewModel.jglbCmd execute:nil];
     }];
    
    // 公示
    [[self.publicityBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
    {
        @strongify(self);
        
        [self _push2PublicityVC];
    }];
    
    // 今日焦点
    [self.todayTableView mh_registerNibCell:[CommonItemCell class]];
    self.todayTableView.delegate = self;
    self.todayTableView.dataSource = self;
    self.todayTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    if (@available(iOS 11.0, *))
    {
        self.todayTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    
    for (NSLayoutConstraint* curConstraint in self.todayTableView.constraints)
    {
        if (curConstraint.firstAttribute == NSLayoutAttributeHeight)
        {
            curConstraint.constant = MHUIScaleValue(212*2.0f);
            
            break;
        }
    }
    
    [[[[RACObserve(self.viewModel.todayFocusTVM, dataSource) distinctUntilChanged]
       filter:^BOOL(id value)
    {
        return value != nil;
    }] deliverOnMainThread]
     subscribeNext:^(id x) {
         @strongify(self)
         
         // 刷新数据
         NSArray* curArr = x;
         
         [self.todayTableView reloadData];
     }];
    
    self.viewModel.todayFocusTVM.didSelectCommand = self.viewModel.todayFocusTVM.selectCmd;
    
    [[self.viewModel.todayFocusTVM.selectCmd.executionSignals.switchToLatest deliverOnMainThread] subscribeNext:^(id x) {
        @strongify(self)
        
        // 点击事件
        CommonItemViewModel* ivm = x;
        
        ArticleListData* aListData = ivm.data;
        
        [self _push2StwxDetailVCByArticleID:aListData.articleID type:aListData.type];
    }];
    
    [self.viewModel.changeTFCmd execute:@{}];
    
    [[self.todayChangeBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
     {
         @strongify(self);
         // 重新请求今日焦点信息
         [self.viewModel.changeTFCmd execute:@{}];
     }];
    
    [[self.todayMoreBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
     {
         @strongify(self);
         
         [self _push2TodayNewsListVC];
     }];
    
    // 环保要闻
    [self.newsTableView mh_registerNibCell:[CommonNewsItemCell class]];
    self.newsTableView.delegate = self;
    self.newsTableView.dataSource = self;
    self.newsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    if (@available(iOS 11.0, *))
    {
        self.newsTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    
    for (NSLayoutConstraint* curConstraint in self.newsTableView.constraints)
    {
        if (curConstraint.firstAttribute == NSLayoutAttributeHeight)
        {
            curConstraint.constant = MHUIScaleValue(94*3.0f);
            
            break;
        }
    }
    
    [[[[RACObserve(self.viewModel.newsTVM, dataSource) distinctUntilChanged]
       filter:^BOOL(id value)
       {
           return value != nil;
       }] deliverOnMainThread]
     subscribeNext:^(id x) {
         @strongify(self)
         
         // 刷新数据
         NSArray* curArr = x;
         
         [self.newsTableView reloadData];
     }];
    
    self.viewModel.newsTVM.didSelectCommand = self.viewModel.newsTVM.selectCmd;
    
    [[self.viewModel.newsTVM.selectCmd.executionSignals.switchToLatest deliverOnMainThread] subscribeNext:^(id x) {
        @strongify(self)
        
        // 点击事件
        
        CommonNewsItemViewModel* ivm = x;
        
        ArticleListData* aListData = ivm.data;
        
        [self _push2StwxDetailVCByArticleID:aListData.articleID type:aListData.type];
    }];
    
    [self.viewModel.changeNewsCmd execute:@{}];
    
    [[self.newsChangeBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
     {
         @strongify(self);
         // 重新请求s环保要闻信息
         [self.viewModel.changeNewsCmd execute:@{}];
     }];
    
    [[self.newsMoreBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
     {
         @strongify(self);
         
         [self _push2NewsListVC];
     }];
    
    [[[self.supermanMoreBtn rac_signalForControlEvents:UIControlEventTouchUpInside] merge:[self.expertMoreBtn rac_signalForControlEvents:UIControlEventTouchUpInside]] subscribeNext:^(id x)
    {
        @strongify(self);
        
        [self _push2ExpertListVC];
    }];
    
    [[[RACObserve(self.viewModel, adImgsData) filter:^BOOL(id value) {
        
        return value != nil;
    }] deliverOnMainThread] subscribeNext:^(id x)
    {
        @strongify(self);
        
        [self _updateBanner];
    }];
    
    [[[RACObserve(self.viewModel, mainIndexData) filter:^BOOL(id value) {
        
        return value != nil;
    }] deliverOnMainThread] subscribeNext:^(id x)
     {
         @strongify(self);
         
         [self _updateMainContent];
     }];
    
    [self.viewModel.reqDataCmd execute:nil];
}

- (void)_setupBanner
{
    // ------ Banner
    SDCycleScrollView* bannerScrollView = (SDCycleScrollView*)[self.bannerView viewWithTag:99];
    if (bannerScrollView == NULL)
    {
        CGSize bannerSize = self.bannerView.frame.size;
        bannerSize = (CGSize) {self.width, (self.width/bannerSize.width)*bannerSize.height};
        SDCycleScrollView* bannerScrollView = [[SDCycleScrollView alloc] initWithFrame:(CGRect) {0, 0, bannerSize}];
        bannerScrollView.tag = 99;
        bannerScrollView.autoScrollTimeInterval = 5;
        //            bannerScrollView.imageURLStringsGroup = @[@"http://img3.redocn.com/tupian/20160108/lvsehuahuizhizhangfanyexiaoguobeijingsucai_5728265.jpg", @"http://pic.58pic.com/58pic/13/76/61/33N58PICRdp_1024.jpg", @"http://img3.redocn.com/tupian/20160108/lvsehuahuizhizhangfanyexiaoguobeijingsucai_5728265.jpg"];
        bannerScrollView.currentPageDotColor = UIColorHex(#ffffffff);
        bannerScrollView.pageDotColor = UIColorHex(#ffffff66);
        bannerScrollView.delegate = self;
        [self.bannerView addSubview:bannerScrollView];
    }
}

- (void)_updateBanner
{
    BannersData* data = self.viewModel.adImgsData;
    NSMutableArray* imgurlArr = [NSMutableArray array];
    for (int index=0; index<data.datas.count; index++)
    {
        BannerData* curData = data.datas[index];
        
        [imgurlArr addObject:curData.image];
    }
    
    SDCycleScrollView* bannerScrollView = (SDCycleScrollView*)[self.bannerView viewWithTag:99];
    if (bannerScrollView != NULL)
    {
        bannerScrollView.imageURLStringsGroup = imgurlArr;
    }
}

- (void)_updateMainContent
{
    @weakify(self);
    
    // 公示
    self.publicityLabel.text = (self.viewModel.mainIndexData.publicityDatas && self.viewModel.mainIndexData.publicityDatas.count > 0) ? self.viewModel.mainIndexData.publicityDatas[0].title : @"";
    
    //更新专家
    NSInteger expertCount = self.viewModel.mainIndexData.expertDatas.count;
    for (NSInteger index=0; index<3; index++)
    {
        UIView* expertView = [self.expertsView viewWithTag:10+index];
        
        UIImageView* avatarImgView = [expertView viewWithTag:100];
        UILabel* tipLabel = [expertView viewWithTag:101];
        UILabel* nameLabel = [expertView viewWithTag:102];
        UIButton* btn = [expertView viewWithTag:103];
        
        if (index < expertCount)
        {
            ExpertListData* expertListData = self.viewModel.mainIndexData.expertDatas[index];
            
            expertView.hidden = NO;
            
            [avatarImgView yy_setImageWithURL:[NSURL URLWithString:expertListData.headImg] placeholder:MHImageNamed(@"placeholderLogo")];
            
            nameLabel.text = expertListData.nickName;
            
            [[btn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
            {
                @strongify(self);
                
                [self _push2ExpertDetailVC:expertListData];
            }];
        }
        else
        {
            expertView.hidden = YES;
        }
    }
    
    //本周生态达人
    NSInteger supermanCount = self.viewModel.mainIndexData.userDatas.count;
    for (NSInteger index=0; index<5; index++)
    {
        UIView* supermanView = [self.supermansView viewWithTag:10+index];
        
        UIImageView* avatarImgView = [supermanView viewWithTag:100];
        UIButton* btn = [supermanView viewWithTag:101];
        
        if (index < supermanCount)
        {
            UserListData* userListData = self.viewModel.mainIndexData.userDatas[index];
            
            supermanView.hidden = NO;
            supermanView.layer.cornerRadius = supermanView.frame.size.height/2.0f;
            supermanView.layer.masksToBounds = YES;
            
            [avatarImgView yy_setImageWithURL:[NSURL URLWithString:userListData.wxHeadImg] placeholder:MHImageNamed(@"placeholderLogo")];
            
            [[btn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
             {
                 @strongify(self);
                 
                 [self _push2UserDetailVC:userListData];
             }];
        }
        else
        {
            supermanView.hidden = YES;
        }
    }
}

#pragma mark -- sub class can override it
///// 上拉事件
//- (void)tableViewDidTriggerFooterRefresh:(SUTableViewModel2*)tableVM
//{
//    @weakify(self);
//
//    NSString* strTableVMName = tableVM.params[@"Name"];
//
//    if ([strTableVMName isEqualToString:@"TodayFocus"])
//    {
//        TodayFocusTableViewModel* curTVM = (TodayFocusTableViewModel*) tableVM;
//
//        NSDictionary* info = @{};
//
//        [[[curTVM.requestDataCmd execute:info] deliverOnMainThread]
//         subscribeNext:^(id x) {
//             @strongify(self)
//             curTVM.page = 1;
//         } error:^(NSError *error) {
//             @strongify(self);
//             [self tableViewDidFinishTriggerHeader:NO reload:NO tableVM:curTVM];
//         } completed:^{
//             @strongify(self)
//             [self tableViewDidFinishTriggerHeader:NO reload:NO tableVM:curTVM];
//         }];
//    }
//}

#pragma mark -- About TableView
- (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath
{
    return [tableView dequeueReusableCellWithIdentifier:identifier];
}

- (void)configureCell:(id)cell atIndexPath:(NSIndexPath*)indexPath withObject:(id)object
{
    if ([cell isKindOfClass:[CommonItemCell class]])
    {
        CommonItemCell* curCell = (CommonItemCell*)cell;
        
        [curCell bindViewModel:object];
    }
    else if ([cell isKindOfClass:[CommonNewsItemCell class]])
    {
        CommonNewsItemCell* curCell = (CommonNewsItemCell*)cell;
        
        [curCell bindViewModel:object];
    }
}

#pragma mark -- UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView.tag == 110)
    {
        return self.viewModel.todayFocusTVM.dataSource.count;
    }
    else if (tableView.tag == 111)
    {
        return self.viewModel.newsTVM.dataSource.count;
    }
    else
    {
        return 0;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    Class cellClass = nil;
    SUTableViewModel2* curTVM = nil;
    
    if (tableView.tag == 110)
    {
        cellClass = [CommonItemCell class];
        curTVM = self.viewModel.todayFocusTVM;
    }
    else if (tableView.tag == 111)
    {
        cellClass = [CommonNewsItemCell class];
        curTVM = self.viewModel.newsTVM;
    }
    else
    {
//        cellClass = [CheckerTextCell class];
    }
    
    UITableViewCell* cell = [self tableView:tableView dequeueReusableCellWithIdentifier:NSStringFromClass(cellClass) forIndexPath:indexPath];
    
    // fetch object
    id object = nil;
    if (curTVM.shouldMultiSections) object = curTVM.dataSource[indexPath.section][indexPath.row];
    if (!curTVM.shouldMultiSections) object = curTVM.dataSource[indexPath.row];
    
    /// bind model
    [self configureCell:cell atIndexPath:indexPath withObject:(id)object];
    
    return cell;
}

#pragma mark -- UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return .0001f;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    /// FIXED : when data is empty ，the backgroundColor is exist
    return .0001f;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    /// 由于使用系统的autoLayout来计算cell的高度，每次滚动时都要重新计算cell的布局以此来获得cell的高度 这样一来性能不好
    /// 所以笔者采用实现计算好的cell的高度
    
    SUTableViewModel2* curTVM = nil;
    
    if (tableView.tag == 110)
    {
        curTVM = self.viewModel.todayFocusTVM;
    }
    else if (tableView.tag == 111)
    {
        curTVM = self.viewModel.newsTVM;
    }
    
    CGFloat cellHeight = 0;
    if (curTVM != nil)
    {
        cellHeight = [curTVM.dataSource[indexPath.row] cellHeight];
    }
    
    return cellHeight;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    // execute commond
    
    SUTableViewModel2* curTVM = nil;
    
    if (tableView.tag == 110)
    {
        curTVM = self.viewModel.todayFocusTVM;
        [curTVM.didSelectCommand execute:self.viewModel.todayFocusTVM.dataSource[indexPath.row]];
    }
    else if (tableView.tag == 111)
    {
        curTVM = self.viewModel.newsTVM;
        [curTVM.didSelectCommand execute:self.viewModel.newsTVM.dataSource[indexPath.row]];
    }
}

#pragma mark - 代理方法
// 设立实现代理，注意要返回UIModalPresentationNone
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
{
    return UIModalPresentationPopover;
}

// SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    //根据index 跳转 图文详情 界面
    BannerData* data = self.viewModel.adImgsData.datas[index];
    
    if (![data.url isNotBlank])
    {
        return;
    }
    
//    ArticleData* articleData = [[ArticleData alloc] init];
//    articleData.url = data.url;
//    
//    EPWebViewModel* vm = [[EPWebViewModel alloc] initWithParams:@{SUViewModelTitleKey:@""}];
//    vm.articleData = articleData;
//    EPWebViewController* vc = [[EPWebViewController alloc] initWithViewModel:vm];
//    
//    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - 跳转
- (void)_push2PublicityVC
{
    ArticleListData* aListData = (self.viewModel.mainIndexData.publicityDatas && self.viewModel.mainIndexData.publicityDatas.count > 0) ? self.viewModel.mainIndexData.publicityDatas[0] : nil;
    
    if (aListData)
    {
        if (aListData.type == 2)
        {
            DocumentDetailViewModel* vm = [[DocumentDetailViewModel alloc] initWithParams:@{}];
            vm.articleID = aListData.articleID;
            DocumentDetailViewController* vc = [[DocumentDetailViewController alloc] initWithViewModel:vm];
            UIViewController* showVC = [UIViewController getCurrentVC];
            
            UINavigationController* navc = showVC.navigationController;
            [navc pushViewController:vc animated:YES];
        }
        else
        {
            StwxDetailViewModel* vm = [[StwxDetailViewModel alloc] initWithParams:@{}];
            vm.articleID = aListData.articleID;
            StwxDetailViewController* vc = [[StwxDetailViewController alloc] initWithViewModel:vm];
            UIViewController* showVC = [UIViewController getCurrentVC];
            
            UINavigationController* navc = showVC.navigationController;
            [navc pushViewController:vc animated:YES];
        }
    }
}

- (void)_push2StwxDetailVCByArticleID:(NSString*)articleID type:(NSInteger)type
{
    if (type == 2)
    {
        DocumentDetailViewModel* vm = [[DocumentDetailViewModel alloc] initWithParams:@{}];
        vm.articleID = articleID;
        DocumentDetailViewController* vc = [[DocumentDetailViewController alloc] initWithViewModel:vm];
        UIViewController* showVC = [UIViewController getCurrentVC];
        
        UINavigationController* navc = showVC.navigationController;
        [navc pushViewController:vc animated:YES];
    }
    else
    {
        StwxDetailViewModel* vm = [[StwxDetailViewModel alloc] initWithParams:@{}];
        //    [vm initStwxDetail:stwxDetailIVM];
        //    vm.isHaveDetailCtrl = NO;
        vm.articleID = articleID;
        StwxDetailViewController* vc = [[StwxDetailViewController alloc] initWithViewModel:vm];
        UIViewController* showVC = [UIViewController getCurrentVC];
        
        UINavigationController* navc = showVC.navigationController;
        [navc pushViewController:vc animated:YES];
    }
}

- (void)_push2ExpertDetailVC:(ExpertListData*)expertListData
{
    STSpaceViewModel* vm = [[STSpaceViewModel alloc] initWithParams:@{SUViewModelTitleKey:MHObjectIsNil(expertListData.nickName)?@"":expertListData.nickName}];
    vm.userID = expertListData.userID;
    STSpaceViewController* vc = [[STSpaceViewController alloc] initWithViewModel:vm];
    
    [[UIViewController getCurrentVC].navigationController pushViewController:vc animated:YES];
}

- (void)_push2ExpertListVC
{
    ExpertListV2ViewModel* vm = [[ExpertListV2ViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"本周明星专家"}];
    ExpertListV2ViewController* vc = [[ExpertListV2ViewController alloc] initWithViewModel:vm];
    [[UIViewController getCurrentVC].navigationController pushViewController:vc animated:YES];
}

- (void)_push2UserDetailVC:(UserListData*)userListData
{
    STSpaceViewModel* vm = [[STSpaceViewModel alloc] initWithParams:@{SUViewModelTitleKey:userListData.wxNickName}];
    vm.userID = userListData.userID;
    STSpaceViewController* vc = [[STSpaceViewController alloc] initWithViewModel:vm];
    
    [[UIViewController getCurrentVC].navigationController pushViewController:vc animated:YES];
}

- (void)_push2TodayNewsListVC
{
    NewsListViewModel* vm = [[NewsListViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"今日焦点"}];
    vm.type = 0;
    vm.areaID = self.viewModel.provinceListData ? self.viewModel.provinceListData.areaID : @"0";
    NewsListViewController* vc = [[NewsListViewController alloc] initWithViewModel:vm];
    [[UIViewController getCurrentVC].navigationController pushViewController:vc animated:YES];
}

- (void)_push2NewsListVC
{
    NewsListViewModel* vm = [[NewsListViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"环保要闻"}];
    vm.type = 1;
    vm.areaID = self.viewModel.provinceListData ? self.viewModel.provinceListData.areaID : @"0";
    NewsListViewController* vc = [[NewsListViewController alloc] initWithViewModel:vm];
    [[UIViewController getCurrentVC].navigationController pushViewController:vc animated:YES];
}

- (void)_push2STS
{
    [MBProgressHUD mh_showTips:@"生态树功能暂未开放"];
}

- (void)_push2JSQ
{
    WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
    launchMiniProgramReq.userName = @"gh_429a1036e971";  //拉起的小程序的username
    launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
    [WXApi sendReq:launchMiniProgramReq];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
